package win.demonlegion.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import win.demonlegion.service.inte.BackgroundThreadService;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;

@Service("backgroundThreadService")
public class BackgroundThreadServiceImpl implements BackgroundThreadService {
    @Autowired
    private ExecutorService executorService;

    @Override
    public <T> Future<T> taskExecute(Callable<T> task) {
        return executorService.submit(task);
    }

    @Override
    public <T> Future<T> taskExecute(Runnable task, T result) {
        return executorService.submit(task, result);
    }

    @Override
    public Future<?> taskExecute(Runnable task) {
        return executorService.submit(task);
    }
}
